﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace 异步过滤器.Filtter
{
    public class TestAsyncFiltter : IAsyncActionFilter
    {
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            Console.WriteLine("请求执行之前做的事" + DateTime.Now);
            //await Task.Delay(3000);
            //经验证异步过滤与同步过滤器在应用层面上没有区别
            //使用异步在高并发场景下能显著提升吞吐量
            await next();
            Console.WriteLine("请求执行之后做的事" + DateTime.Now);
        }
    }
}